<template>
  <div class="newCourseSchedule">
    <el-breadcrumb separator="/" class="breadcrumb-bottom">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>课程管理</el-breadcrumb-item>
      <el-breadcrumb-item>新增课程进度表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-form ref="form" :model="form" label-width="100px" class="content fixed-form">
      <el-form-item label="上传者">
        <el-input v-model="form.uplodePerson" placeholder=""></el-input>
      </el-form-item>
      <el-form-item label="上传时间">
        	<el-date-picker type="date" placeholder="选择日期" v-model="form.uplodeTime" style="width: 100%;"></el-date-picker>
      </el-form-item>
      <el-form-item label="课程进度表">
        <el-upload
            class="upload-demo"
            action="http://localhost:8080/TeachingMIS/teachingSchedule/uploadSchedule"
            :on-success="setFileID">
            <el-button size="small" type="primary">点击上传</el-button>
         </el-upload>
      </el-form-item>
      <el-form-item label="备注">
        <el-input type="textarea" :rows="6" v-model="form.remark"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    name: 'newCourseSchedule',
    data () {
      return {
        form: {
          teacherCourseID:'',
          uplodePerson:'',
          uplodeTime:'',
          fileID:'',
          remark: '',

        },
        url: 'http://localhost:8080/TeachingMIS'
      }
    },
    created(){
      this.getTeacherCourseID()
    },
    methods: {
      getTeacherCourseID(){
        this.form.teacherCourseID = this.$route.query.teacherCourseID;
      },
      onSubmit() {
        this.$http.post(`${this.url}/teachingSchedule/addSchedule`,this.form).then((res)=>{
		  console.log("提交成功");
          alert("提交成功");
        }, (err) => {
          console.log("服务器异常！");
          alert("提交失败");
        })
      },
      setFileID(fileID,file){
        	this.form.fileID=fileID;
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
